The following encoder is described as a conventional optical encoder in Patent Document 1. Specifically, light is projected toward an optical scale in which a plurality of grating windows consisting of different types of diffraction gratings are arranged at intervals of a predetermined distance, and a two-dimensional image sensor takes an image of a pattern of diffracted light diffracted by a grating window. Then the encoder specifies the grating window on the basis of the taken pattern of diffracted light, and specifies the position of the grating window in the operational direction of the optical scale on the basis of the position of the pattern of diffracted light in the image, thereby detecting an operating distance of the optical scale.
Patent Document 1: Japanese Patent Publication No. 8-10145